/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ita.controller;

import br.ita.model.dao.DAO;
import br.ita.model.dao.GenericDAO;
import br.ita.model.dao.PointsDAO;
import br.ita.model.entities.Points;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Gustavo
 */
@WebServlet(name = "points", urlPatterns = {"/points"})
public class PointsController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        String profileId = request.getParameter("profileid");
        String points = request.getParameter("points");
        int pointsInt = Integer.parseInt(points);
        
        Points userPoints = new Points();
        userPoints.setIdPerfil(profileId);
        userPoints.setPontosDoUsuario(pointsInt);
        
        DAO banco = new PointsDAO();
        try{
            banco.insert(userPoints);
            response.getWriter().print("Deu certo");
        }
        catch(Exception e)
        {
            response.getWriter().print("Não deu certo");
        }
    }
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
    }
}
